<template>
  <div id="app">
<!--    <MyTree :data="data"></MyTree>-->
    <input type="hidden" id="defaultExpandKeysId" v-model="defaultExpandKeys">
    <input type="hidden" id="currentLivingId" v-model="currentLivingId">
    <LazyTree ref="childData" :data="data"></LazyTree>
  </div>
</template>

<script>
import {getTreeList} from "./api";
import MyTree from "./MyTree";
import LazyTree from "./LazyTree";

export default {
  data(){
    return {
      data:[],
      defaultExpandKeys:[],
      currentLivingId: ""
    }
  },
  components:{
    MyTree,
    LazyTree,
  },
  async mounted() {
    // this.defaultExpandKeys = this.$refs.childData.defaultExpandKeys;
    // this.$refs.childData.defaultExpandKeys = this.defaultExpandKeys;

    // let {data} = await getTreeList();
    // if(data.code === 20000) {
    //   // 如果查询到数据
    //   let geocode = data.geocode;
    //   console.log([geocode]);
    //   this.data = [geocode];
    // }
  },
  watch:{
    defaultExpandKeys:{
      handler(newData,oldData){
        // console.log("修改前" + oldData + "---修改后" + newData);
        this.$refs.childData.defaultExpandKeys = this.defaultExpandKeys.split(',');
      },
      deep: true
    },
    // currentLivingId:{
    //   handler(newData, oldData) {
    //     this.$refs.childData.currentLivingId = this.currentLivingId;
    //   },
    //   deep: true
    // },
  }
}
</script>
<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
